package com.tust.app.service.impl;

import com.tust.app.dao.AnswerMapper;
import com.tust.app.domain.Answer;
import com.tust.app.service.AnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class AnswerServiceImpl implements AnswerService {

    @Autowired
    private AnswerMapper AnswerMapper;

    @Override
    public List<Answer> selectByTopicId(Integer id){
        return AnswerMapper.selectByTopicId(id);
    };

    @Override
    public List<Answer> serchByUserName(String username){
        if (username != null && username.length() > 0){
            return AnswerMapper.selectByUsername(username);
        }else {
            return AnswerMapper.selectAllAnswers();
        }
    };

    @Override
    public List<Answer> answersList(){
        return AnswerMapper.selectAllAnswers();
    }
    @Override
    public int deleteByPrimaryKey(Integer id) {
        return AnswerMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Answer record) {
        return AnswerMapper.insert(record);
    }

    @Override
    public int insertOrUpdate(Answer record) {
        return AnswerMapper.insertOrUpdate(record);
    }

    @Override
    public int insertOrUpdateSelective(Answer record) {
        return AnswerMapper.insertOrUpdateSelective(record);
    }

    @Override
    public int insertSelective(Answer record) {
        return AnswerMapper.insertSelective(record);
    }

    @Override
    public Answer selectByPrimaryKey(Integer id) {
        return AnswerMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Answer record) {
        return AnswerMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Answer record) {
        return AnswerMapper.updateByPrimaryKey(record);
    }

    @Override
    public int updateBatch(List<Answer> list) {
        return AnswerMapper.updateBatch(list);
    }

    @Override
    public int updateBatchSelective(List<Answer> list) {
        return AnswerMapper.updateBatchSelective(list);
    }

    @Override
    public int batchInsert(List<Answer> list) {
        return AnswerMapper.batchInsert(list);
    }

}
